﻿Imports System.Data.SqlClient
Imports PhDir.Model

Namespace Repository.DataReader
    Public Class UserReader
        Implements IDataReader(Of Model.User)

        Friend Sub New()
            Me.DepartmentReader = New DepartmentReader
        End Sub

        Private Property DepartmentReader As DepartmentReader

        Public Function Read(sqlDataReader As SqlDataReader) As Model.User _
            Implements IDataReader(Of Model.User).Read

            Dim department = Me.DepartmentReader.Read(sqlDataReader)
            Dim user = New Model.User With
                       {
                           .Department = department,
                           .UserId = sqlDataReader("UserId"),
                           .UserName = sqlDataReader("Name")
                       }
            Return user

        End Function

    End Class
End Namespace
